﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using System.Windows.Controls;
using Microsoft.Practices.Prism.Logging;
using Microsoft.Practices.Prism.MefExtensions.Modularity;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.ServiceLocation;
using SearchScreen.SearchScreenModule.View;

namespace SearchScreen.SearchScreenModule
{
    [ModuleExport(typeof(SearchModule))]
    public class SearchModule : IModule
    {
        
        IRegionManager RegionManager;

        public Dictionary<string, Control> ModulesComponents;

        [ImportingConstructor]
        public SearchModule(IRegionManager regionManager)
        {
            RegionManager = regionManager;
        }
        
        public void Initialize()
        {
           // Load the Main Region, referenced in the Shell
            RegionManager = (IRegionManager)ServiceLocator.Current.GetInstance(typeof(IRegionManager));
            RegionManager.Regions["SearchScreenModule"].Add(new SearchScreenModuleView());

            // Load the 4 Local Regions
            RegionManager = (IRegionManager)ServiceLocator.Current.GetInstance(typeof(IRegionManager));
            RegionManager.Regions["MenuBar"].Add(new MenuBarView());

            RegionManager = (IRegionManager)ServiceLocator.Current.GetInstance(typeof(IRegionManager));
            RegionManager.Regions["CriteriaTuple"].Add(new CriteriaTupleView());

            RegionManager = (IRegionManager)ServiceLocator.Current.GetInstance(typeof(IRegionManager));
            RegionManager.Regions["DomainTypes"].Add(new DomainTypesView());

            RegionManager = (IRegionManager)ServiceLocator.Current.GetInstance(typeof(IRegionManager));
            RegionManager.Regions["RequestEditor"].Add(new RequestEditorView());

        }
    }
}
